plotHawkCoefs = function(append="") {

  meanFits = paste0("meanFit1", c("a", "b", "c", "d"), append)
  leaderFits = paste0("leaderFit1", c("a", "b", "c", "d"), append)
  compFits = paste0("compFit1", c("a", "b", "c", "d"), append)
  
  allFits = c(meanFits, leaderFits, compFits)
  
  mCoefs = mSEs = NA
  for (i in 1:length(allFits)) {
    
    if (grepl("meanFit|leaderFit", allFits[i])) {
      mCoefs[i] = coef(get(allFits[i]))[2]
      mSEs[i] = sqrt(diag(vcov(get(allFits[i]))))[2]
    } else {
      advInd = grep("advHawk", names(coef(get(allFits[i]))))
      mCoefs[i] = coef(get(allFits[i]))[advInd]
      mSEs[i] = sqrt(diag(vcov(get(allFits[i]))))[advInd]
    }
    

  }

  figData = data.frame(coefs = mCoefs, se = mSEs)
  
  figData$low = figData$coefs - 1.96*figData$se
  figData$low10 = figData$coefs - 1.69*figData$se
  figData$high = figData$coefs + 1.96*figData$se
  figData$high10 = figData$coefs + 1.69*figData$se
  
  figData$Model = c("Sparse", "With controls")
  figData$Mechanism = rep(c("Emergence Model\n(Coefficient for Group Mean)", 
                            "Leader Model\n(Coefficient for President)", 
                            "Adviser Model\n(Coefficient for Advisers)"), each=4)
  figData$Mechanism = factor(figData$Mechanism,
                             levels=c("Emergence Model\n(Coefficient for Group Mean)", 
                             "Leader Model\n(Coefficient for President)", 
                             "Adviser Model\n(Coefficient for Advisers)"))
  
  figData$Label = rep(c("Conf.\n(Poisson)\nSparse", "Conf.\n(Poisson)\nFull", "Conf.-Coop.\n(OLS)\nSparse", "Conf.-Coop.\n(OLS)\nFull"), 3)
  figData$Label = factor(figData$Label, levels=c("Conf.\n(Poisson)\nSparse", "Conf.\n(Poisson)\nFull", "Conf.-Coop.\n(OLS)\nSparse", "Conf.-Coop.\n(OLS)\nFull"))
  
  figData$signif = ifelse((figData$coefs > 0 & figData$low > 0) | (figData$coefs < 0 & figData$high < 0), "Yes", "No")
  
  figSave = ggplot(figData, aes(x=Label, y=mCoefs)) + 
    geom_pointrange(aes(ymin=low, ymax=high, color=Label, shape=signif)) + 
    geom_linerange(aes(ymin=low10, ymax=high10, color=Label), linewidth=1.5) + 
    geom_hline(yintercept=0, linetype=2) + theme_bw() + ylab("Coefficient Estimate") + 
    xlab("Model") + 
    scale_color_manual("Model", values=c("tomato", "red3", "dodgerblue", "royalblue3")) + 
    facet_grid(cols=vars(Mechanism)) +
    theme(legend.position="none", axis.text.x = element_text(angle=90, vjust=0.5)) +
    scale_shape_manual(values=c(16,15))
  
  figSave
}


plotMainHawkCoefs = function(append="") {
  
  meanFits = paste0("meanFit1", c("b", "d"), append)
  leaderFits = paste0("leaderFit1", c("b", "d"), append)
  compFits = paste0("compFit1", c("b", "d"), append)
  
  allFits = c(meanFits, leaderFits, compFits)
  
  mCoefs = mSEs = NA
  for (i in 1:length(allFits)) {
    
    if (grepl("meanFit|leaderFit", allFits[i])) {
      mCoefs[i] = coef(get(allFits[i]))[2]
      mSEs[i] = sqrt(diag(vcov(get(allFits[i]))))[2]
    } else {
      advInd = grep("advHawk", names(coef(get(allFits[i]))))
      mCoefs[i] = coef(get(allFits[i]))[advInd]
      mSEs[i] = sqrt(diag(vcov(get(allFits[i]))))[advInd]
    }
    
    
  }
  
  figData = data.frame(coefs = mCoefs, se = mSEs)
  
  figData$low = figData$coefs - 1.96*figData$se
  figData$low10 = figData$coefs - 1.69*figData$se
  figData$high = figData$coefs + 1.96*figData$se
  figData$high10 = figData$coefs + 1.69*figData$se
  
  figData$Model = c("Sparse", "With controls")
  figData$Mechanism = rep(c("Emergence Model\n(Coefficient for Group Mean)", 
                            "Leader Model\n(Coefficient for President)", 
                            "Adviser Model\n(Coefficient for Advisers)"), each=2)
  figData$Mechanism = factor(figData$Mechanism,
                             levels=c("Emergence Model\n(Coefficient for Group Mean)", 
                                      "Leader Model\n(Coefficient for President)", 
                                      "Adviser Model\n(Coefficient for Advisers)"))
  
  figData$Label = rep(c("Conf.\n(Poisson)", "Conf.-Coop.\n(OLS)"), 3)
  figData$Label = factor(figData$Label, levels=c("Conf.\n(Poisson)", "Conf.-Coop.\n(OLS)"))
  
  figData$signif = ifelse((figData$coefs > 0 & figData$low > 0) | (figData$coefs < 0 & figData$high < 0), "Yes", "No")
  
  figSave = ggplot(figData, aes(x=Label, y=mCoefs)) + 
    geom_pointrange(aes(ymin=low, ymax=high, color=Label, shape=signif)) + 
    geom_linerange(aes(ymin=low10, ymax=high10, color=Label), linewidth=1.5) + 
    geom_hline(yintercept=0, linetype=2) + theme_bw() + ylab("Coefficient Estimate") + 
    xlab("Model") + 
    scale_color_manual("Model", values=c("red3", "royalblue3")) + 
    facet_grid(cols=vars(Mechanism)) +
    theme(legend.position="none", axis.text.x = element_text(angle=90, vjust=0.5)) +
    scale_shape_manual(values=c(16,15))
  
  figSave
}



plotNBHawkCoefs = function(append="") {
  
  meanFits = paste0("meanFit1", c("a", "b"), append)
  leaderFits = paste0("leaderFit1", c("a", "b"), append)
  compFits = paste0("compFit1", c("a", "b"), append)
  
  allFits = c(meanFits, leaderFits, compFits)
  
  mCoefs = mSEs = NA
  for (i in 1:length(allFits)) {
    
    if (grepl("meanFit|leaderFit", allFits[i])) {
      mCoefs[i] = coef(get(allFits[i]))[2]
      mSEs[i] = sqrt(diag(vcov(get(allFits[i]))))[2]
    } else {
      advInd = grep("advHawk", names(coef(get(allFits[i]))))
      mCoefs[i] = coef(get(allFits[i]))[advInd]
      mSEs[i] = sqrt(diag(vcov(get(allFits[i]))))[advInd]
    }
    
    
  }
  
  figData = data.frame(coefs = mCoefs, se = mSEs)
  
  figData$low = figData$coefs - 1.96*figData$se
  figData$low10 = figData$coefs - 1.69*figData$se
  figData$high = figData$coefs + 1.96*figData$se
  figData$high10 = figData$coefs + 1.69*figData$se
  
  figData$Model = c("Sparse", "With controls")
  figData$Mechanism = rep(c("Emergence Model\n(Coefficient for Group Mean)", 
                            "Leader Model\n(Coefficient for President)", 
                            "Adviser Model\n(Coefficient for Advisers)"), each=2)
  figData$Mechanism = factor(figData$Mechanism,
                             levels=c("Emergence Model\n(Coefficient for Group Mean)", 
                                      "Leader Model\n(Coefficient for President)", 
                                      "Adviser Model\n(Coefficient for Advisers)"))
  
  figData$Label = rep(c("Conf.\n(Neg. Bin.)\nSparse", "Conf.\n(Neg. Bin.)\nFull"), 3)
  figData$Label = factor(figData$Label, levels=c("Conf.\n(Neg. Bin.)\nSparse", "Conf.\n(Neg. Bin.)\nFull"))
  
  figData$signif = ifelse((figData$coefs > 0 & figData$low > 0) | (figData$coefs < 0 & figData$high < 0), "Yes", "No")
  
  figSave = ggplot(figData, aes(x=Label, y=mCoefs)) + 
    geom_pointrange(aes(ymin=low, ymax=high, color=Label, shape=signif)) + 
    geom_linerange(aes(ymin=low10, ymax=high10, color=Label), linewidth=1.5) + 
    geom_hline(yintercept=0, linetype=2) + theme_bw() + ylab("Coefficient Estimate") + 
    xlab("Model") + 
    scale_color_manual("Model", values=c("red3", "royalblue3")) + 
    facet_grid(cols=vars(Mechanism)) +
    theme(legend.position="none", axis.text.x = element_text(angle=90, vjust=0.5)) +
    scale_shape_manual(values=c(16,15))
  
  figSave
}
